package yang.yu.sunny.infra.elasticsearch;

import org.elasticsearch.client.Client;
import yang.yu.sunny.domain.product.Product;

import java.util.Collection;
import java.util.Map;

import static java.util.stream.Collectors.toMap;

/**
 * Created by yyang on 16/4/11.
 */
public class ProductSearcher extends AbstractSearcher<Product> {

    public ProductSearcher(Client client) {
        super(client);
    }

    @Override
    protected String getType() {
        return "product";
    }

    @Override
    protected Class getDocClass() {
        return Product.class;
    }

    public Map<Long, String> namesOf(Collection<Long> ids) {
        return findById(ids).stream().collect(toMap(Product::getId, Product::getName));
    }
}
